<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>货品受损</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">
    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
</head>

<body>
    <div class="page-group">
        <div class="page page-current" id="editCommodity">
            <!-- 主内容 -->
            <div class="content">
                <div class="bs-box">
                    <div class="bs-box-content">
                        <div class="bs-box-inner">
                            <div class="bs-box-content-item width-link size-m">
                                <div>受损时间</div>
                                <div>
                                    <input placeholder="请选择受损时间" id ='datetime-picker' value="{if isset($info.damage_at)}{$info.damage_at|substr=0,10}{/if}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item">
                                <p class="size-m">受损原因</p>
                                <div>
                                    <textarea class="size-m" type="text" placeholder="受损原因" id="damage_result">{if isset($info.damage_result)}{$info.damage_result }{/if}</textarea>
                                </div>
                            </div>
                            <div class="bs-box-content-item width-link border-b-none">
                                <p class="size-m">货品所在地区</p>
                                <div>
                                    <input class="size-m" type="text" placeholder="请选择区域"  id="city" value="{if isset($addr) && !empty($addr)}{$addr}{/if}"/>
                                </div>
                            </div>
                            <div class="bs-box-content-item"><input type="text" placeholder="详细门牌地址" class="size-m" value="{if isset($info.address_detail)}{$info.address_detail } {/if}" name="address"></div>

                            <div class="bs-box-content-item border-b-none">
                                <p class="size-m">第三方报告(选填)</p>
                                <div class="uploader">
                                    <ul id="uploader-files" class="uploader-files">
                                        <li class="uploader-file" style="background-image: url(&quot;http://temp.im/288x288/FF9500/000&quot;);">
                                            </li>
                                    </ul>
                                    <div class="uploader-content">
                                        <div class="uploader-input-box"><input type="file" accept="image/*" class="uploader-input"></div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <input type="hidden" value="{$policy_num}" name ='policy_num'>
                <input type="hidden" value="{$p_id}" name ='p_id'>
                <div class="btn-box">
                    <div class="my-btn" @click="login" style="margin-top: 1rem;" id="submit">
                        <span class="active size-m">保存</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-city-picker.min.js' charset='utf-8'></script>
</body>
<script>
    $(function () {
        // setAddres();
        // function   setAddres() {
        //     $str='';
        //     if({if isset($info.omit)} != ''){
        //         $str +=($info.omit);
        //     }
        //     console.log({$info.omit});
        //
        // }
        var myDate = new Date();
        var year = myDate.getFullYear();//获取年
        var month = myDate.getMonth()+1;////获取月
        var day = myDate.getDate();//获取日
        if (month < 10) month = "0" + month;
        if (day < 10) day = "0" + day;
        var time = year+"-"+month+"-"+day;
        var n = $('.step-box').children().length;
        $('.step-item').css('width', document.body.clientWidth / n + 'px')
        $("#datetime-picker").calendar({
            value: [time]
        });
        $("#city").cityPicker({
        });
        $(document).on('click', '#submit', function () {
            var poliecy = $("input[ name='policy_num']").val();
            var p_id = $("input[ name='p_id']").val();
            var damage_at= $("#datetime-picker").val();
            var damage_result= $("#damage_result").val();
            var addr= $("#city").val();
            var a= addr.split(' ');
          if(a.length ==2){
              var omit='';
              var city=a[0];
              var classify=a[1];
          }else if(a.length ==3){
              if(a[2] != ''){
                  var omit=a[0];
                  var city=a[1];
                  var classify=a[2];
              }else {
                  var omit=a[2];
                  var city=a[0];
                  var classify=a[1];
              }
          }

            var address_detail = $("input[ name='address']").val();

            $.ajax({
                type: 'POST',
                url: "{:url('Insurer/update')}",
                data: {
                    'policy_num': poliecy,
                    'damage_at': damage_at,
                    'damage_result': damage_result,
                    'omit': omit,
                    'city': city,
                    'classify': classify,
                    'address_detail':address_detail,
                    'other_report':'www.92.wukai.com',
                },
                dataType: 'json',
                success: function (Json) {
                    if (Json.code == 200) {
                        location.href="{:url('Insurer/insurerInfo')}?p_id="+p_id;
                    } else {
                        $.alert('保存失败');
                    }
                }
            });
        });

    });

</script>


</html>